package com.some;

import java.io.*;
import java.util.*;

class Solution {
    // 首先求得这些不同数字的排列组合，然后拿出这些排列组合进行筛选
    int maxVal = Integer.MIN_VALUE;
    double resultNum = 0;

    public void zhengChu() {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt(); // 小球数量
        int k1 = scanner.nextInt(); // 参数1
        int k2 = scanner.nextInt(); //参数2
        int[] bolls = new int[num]; // 小球
        HashMap<Integer, Boolean> map = new HashMap<>();
        for (int i = 0; i < num; i++) {
            bolls[i] = scanner.nextInt();
            map.put(bolls[i], false);
        }
        dfs(new ArrayList<>(), map, new ArrayList<>(), bolls, k1, k2, 0);
        System.out.println(maxVal + " " + (int) (resultNum > 998244353L ? resultNum % 998244353L : resultNum));
    }

    // 利用深度递归得出这些球的组合
    public void dfs(List<List<Integer>> results, Map<Integer, Boolean> map, List<Integer> res, int[] bolls, int k1, int k2, int index) {
        if (index >= bolls.length || results.contains(res)) {
            return;
        }
        // 判断符合条件的组合
        if (!results.contains(res)) {
            results.add(new ArrayList<>(res));
            int sum = 0;
            for (Integer re : res) {
                sum += re;
            }
            if (sum % k1 == 0 && sum % k2 != 0) {
                resultNum++;
                maxVal = Math.max(maxVal, sum);
            }
        }
        for (int i = index; i < bolls.length; i++) {
            // 这个球没有被拿过
            if (!map.get(bolls[i])) {
                map.put(bolls[i], true);
                res.add(bolls[i]);
                res.sort(Comparator.comparingInt(o -> o));
                dfs(results, map, res, bolls, k1, k2, i);
                map.put(bolls[i], true);
            }
        }

    }
}

class Main {
    public static void main(String args[]) {
        Solution s = new Solution();
        s.zhengChu();
    }
}
